package response

import (
	"soma-server/pkg/e"

	"github.com/gin-gonic/gin"
)

type ResponseData struct {
	Code    int `json:"code,omitempty"`
	Success bool `json:"success"`
	Data    interface{} `json:"data"`
	Message string `json:"message,omitempty"`
}

// 返回新前端
func Response(c *gin.Context, httpStatus int, code int, data interface{}, success bool) {
	result := ResponseData{
		Code: code,
		Success: success,
		Data: data,
		Message: e.GetMsg(code),
	}
	
	c.JSON(httpStatus, result)
}
